﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FreeDream.Model
{
    /// <summary>
    /// 通用分页类
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class PageModel<T>
    {
        public PageModel()
        {
        }

        public PageModel(int page, int pageSize, int dataCount, List<T> data)
        {
            this.Page = page;
            DataCount = dataCount;
            PageSize = pageSize;
            Data = data;
        }


        /// <summary>
        /// 当前页标
        /// </summary>
        public int Page { get; set; } = 1;

        /// <summary>
        /// 总页数
        /// </summary>
        public int PageCount => (int)Math.Ceiling((decimal)DataCount / PageSize);

        /// <summary>
        /// 数据总数
        /// </summary>
        public int DataCount { get; set; } = 0;

        /// <summary>
        /// 每页大小
        /// </summary>
        public int PageSize { set; get; } = 20;

        /// <summary>
        /// 返回数据
        /// </summary>
        public List<T> Data { get; set; }
    }
}
